#!/bin/bash

echo "Starting Into_IoTDB Service..."

# 检查Java环境
if ! command -v java &> /dev/null; then
    echo "Error: Java is not installed or not in PATH"
    exit 1
fi

# 检查Maven环境
if ! command -v mvn &> /dev/null; then
    echo "Error: Maven is not installed or not in PATH"
    exit 1
fi

# 创建必要的目录
mkdir -p uploads/chunks
mkdir -p logs

echo "Creating necessary directories..."

# 编译项目
echo "Compiling project..."
mvn clean compile
if [ $? -ne 0 ]; then
    echo "Error: Compilation failed"
    exit 1
fi

# 启动应用
echo "Starting application..."
mvn spring-boot:run
